#!/bin/bash

##  UIScripts trunk for Ubuntu 10.04 Lucid Lynx LTS
##  Copyright (C) 2010  Batosz 'Simek' Kaszubowski & Marcin 'Marq' Maciaszek
##
##  This program is free software: you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation, either version 3 of the License, or
##  (at your option) any later version.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program.  If not, see <http://www.gnu.org/licenses/>.

##  Contact
##  E-mails: bartoszkaszubowsk@gmail.com / marcin.maciaszek@gmail.com
##  URL: https://code.google.com/p/uiscripts/


##  Translation
################


languages=( *.lang )
langList=( ${languages[@]%.lang} )

lang=$(zenity --list --title="Language selection" --text="Select language:" --window-icon "./ui.png" --radiolist  --column "Pick" --column "Language" TRUE ${langList[@]::1} $(printf 'FALSE %s\n' ${langList[@]:1}))

if [ -z ${lang} ]; then
	zenity --error --text="Error"
	exit
fi

j=1

traFile=`cat "$lang".lang`

IFS=$'\n'
for i in $traFile
do
	export tra${j}=${i}
	let j+=1
done

##  Main Part
################

rozsz=$(zenity --entry --title=$tra2 --text=$tra3 --entry-text "mp3" --window-icon "./ui.png")

if [ -z ${rozsz} ]; then
	zenity --error --text=$tra4
else
	if zenity --question --text="$tra5 '$rozsz' $tra6"; then
		co=$(zenity --list --text $tra7 --radiolist  --column $tra11 --column $tra12 TRUE $tra8 FALSE $tra9 FALSE $tra10)
		if [ "$co" ==  $tra8 ] ; then
			find . -regex '.*\.'$rozsz'*' -exec rm -v '{}' | zenity --text-info --width 530 --window-icon "./ui.png" \;
			zenity --info --text "$tra13 '$rozsz' $tra14"
		elif [ "$co" == $tra9 ] ; then
			find . -regex '.*\.'$rozsz'*' -exec rm -v '{}' \;
			zenity --info --text "$tra13 '$rozsz' $tra14 Lista usuniętych pliĸów widoczna jest w oknie terminalu."
		elif [ "$co" == $tra10 ] ; then
			find . -regex '.*\.'$rozsz'*' -exec rm -v '{}' > ./usunietepliki.txt \;
			zenity --info --text "$tra13 '$rozsz' $tra14 Lista usuniętych pliĸów została zapisana do pliku 'usunietepliki.txt' w lokalizacji skryptu."
		else
			zenity --error --text=$tra1
		fi
	else
		zenity --error --text=$tra1
	fi
fi
